import {v4} from 'uuid'

export function getUserTempId(){
	//尝试从local中读取之前存入的userTempId
	const userTempId = localStorage.getItem('USER_TEMP_ID')
	//若有userTempId
	if(userTempId){
		return userTempId
	}else{
		//生成一个新的临时标识（userTempId）
		const newUserTempId = v4()
		//存入local中
		localStorage.setItem('USER_TEMP_ID',newUserTempId)
		//返回newUserTempId
		return newUserTempId
	}
}

//从local中读取用户的token
export function getUserToken(){
	return localStorage.getItem('USER_TOKEN') || ''
}

//将token保存到local中
export function setUserToken(token){
	localStorage.setItem('USER_TOKEN',token)
}

//将token保存到local中
export function deleteUserToken(){
	localStorage.removeItem('USER_TOKEN')
}

